import React, { Component } from 'react'
import './index.css'

export default class Slider extends Component {
    state={
        subNav:[
            {
                id:'news_list',
                name:'消息列表'
            },
            {
                id:'news_add',
                name:'添加消息'
            }]
    }

    render() {
        const {subNav} = this.state;
        const {defaultIndex,setDefaultIndex} = this.props;
        return (
            <div className="slider">
                <div className="menu" onClick={()=>this.props.history.push('/work')}>工作台</div>
                <div className="menu">消息管理</div>
                {
                    subNav.map((jtem,index)=><div key={jtem.id} className={['menu_sub',defaultIndex===index?'active':''].join(' ')} onClick={()=>setDefaultIndex(index)}>{jtem.name}</div>)
                }
            </div>
        )
    }
}
